package panel.eating
{
	import assists.HtmlText;
	import assists.Lang;
	import assists.TextFieldUtils;
	import assists.resource.ResourceLoader;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	public class GetMoreBox extends Sprite
	{
		private var text:TextField;
		
		private var _stage:Stage;
		private var _loader:ResourceLoader;
		private var _lang:Lang;
		
		private var _onCallBack:Function;
		
		public var outStarNum:Number = 0;
		public var outDistance:Number = 999999;
		public var currentLoaction:Array = [];
		
		public function GetMoreBox(stage:Stage,loader:ResourceLoader,lang:Lang,callBack:Function = null)
		{
			_stage = stage;
			_loader = loader;
			_lang = lang;
			
			_onCallBack = callBack;
			
			initThis();
		}
		
		private function initThis():void
		{
			var shape:Sprite = new Sprite();
			shape.graphics.beginFill(0x000000,0);
			shape.graphics.drawRect(0,0,_stage.stageWidth,_stage.stageHeight * .1);
			shape.graphics.endFill();
			this.addChild(shape);
			
			text = new TextField;
			text.mouseEnabled = false;
			text.multiline = false;
			text.autoSize = TextFieldAutoSize.CENTER;
			
			this.addChild(text);
			TextFieldUtils.setHtmlText(text,HtmlText.formatSizeColor("点击获取更多",0xFFFF00),true,true);
			text.width = text.textWidth + 1;
			text.height = text.textHeight + 1;
			text.x = (_stage.stageWidth - text.width) / 2;
			text.y = (_stage.stageHeight * .1 - text.height) / 2;
			
			this.addEventListener(MouseEvent.CLICK,getMoreHandler);
		}
		
		protected function getMoreHandler(event:MouseEvent):void
		{
			if(_onCallBack is Function){
				_onCallBack();
			}
		}
		
		public function clearThis():void
		{
			if(_stage){
				_onCallBack = null;
				_stage = null;
				_loader = null;
				_lang = null;
			}
		}
	}
}